package com.zhuss.controller.product;

import com.zhuss.bean.bo.product.train.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.common.BaseController;
import com.zhuss.common.OperateService;
import com.zhuss.exception.DzcxException;
import com.zhuss.product.train.TrainOperateServiceExt;


/**
 * @description: 车次操作的Controller
 * @author: zhushanshuo
 * @create: Mon Jan 04 08:55:12 CST 2021
 **/
@RestController
@RequestMapping("/train")
public class TrainOperateController extends BaseController {

	@Autowired
	@Qualifier("trainOperateService")
	private OperateService<Void, Object> trainOperateService;

	@Autowired
	@Qualifier("trainOperateServiceExt")
	private TrainOperateServiceExt trainOperateServiceExt;

	/**
	 * 创建
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
    @PostMapping("/create")
    public void create(@RequestBody CreateTrainBo bo) throws DzcxException {

		trainOperateService.create(bo);
    }


	/**
	 * 修改
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
    @PostMapping("/update")
    public void update(@RequestBody UpdateTrainBo bo) throws DzcxException {

		trainOperateService.update(bo);
    }

	/**
	 * 删除
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
    @PostMapping("/delete")
    public void delete(@RequestBody DeleteTrainBo bo) throws DzcxException {

		trainOperateService.delete(bo);
    }

	/**
	 * 启用
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/start")
	public void start(@RequestBody StartTrainBo bo) throws DzcxException {

		trainOperateServiceExt.start(bo);
	}

	/**
	 * 停用
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/stop")
	public void stop(@RequestBody StopTrainBo bo) throws DzcxException {

		trainOperateServiceExt.stop(bo);
	}

	/**
	 * 是否可以售卖10-可以，20-不可以
	 * @param bo
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/sell")
	public void sell(@RequestBody SellTrainBo bo) throws DzcxException {

		trainOperateServiceExt.sell(bo);
	}






}
